﻿// -------------------------------------------------------------------------
//    @FileName         :    NFWelfarePart.cpp
//    @Author           :    gaoyi
//    @Date             :    24-8-30
//    @Email            :    445267987@qq.com
//    @Module           :    NFWelfarePart
//
// -------------------------------------------------------------------------

#include "NFWelfarePart.h"

#include <NFComm/NFCore/NFTimeUtility.h>

#include "proto_cs_login.pb.h"
#include "proto_db.pb.h"

NFWelfarePart::NFWelfarePart()
{
    if (EN_OBJ_MODE_INIT == NFShmMgr::Instance()->GetCreateMode())
    {
        CreateInit();
    }
    else
    {
        ResumeInit();
    }
}

NFWelfarePart::~NFWelfarePart()
{
}

int NFWelfarePart::CreateInit()
{
    return 0;
}
    
int NFWelfarePart::ResumeInit()
{
    return 0;
}

int NFWelfarePart::LoadFromDB(const proto_ff::tbRoleDetail *pDBData)
{
    m_stData.FromPb(pDBData->role_play_data().welfare_data());
    return 0;
}

int NFWelfarePart::InitConfig(proto_ff::tbRoleDetail *pDbData, const RoleOne &stRoleOne)
{
    CHECK_NULL(0, pDbData);
    auto pExpData = pDbData->mutable_role_play_data()->mutable_welfare_data();
    CHECK_NULL(0, pExpData);

    pExpData->set_day_refresh_time(NFTimeUtility::GetTodayStartTime(NF_ADJUST_TIMENOW()));
    pExpData->set_week_refresh_time(NFTimeUtility::GetWeekStartTime(NF_ADJUST_TIMENOW()));
    pExpData->set_cur_exp(0);
    return 0;
}

int NFWelfarePart::SaveDB(proto_ff::tbRoleDetail *pDBData)
{
    m_stData.ToPb(pDBData->mutable_role_play_data()->mutable_welfare_data());
    return 0;
}

int NFWelfarePart::MakePlayerDataCS(proto_ff::Proto_CSGetRoleRsp* pCSGetRoleRsp)
{
    m_stData.ToPb(pCSGetRoleRsp->mutable_welfare_data());
    return 0;
}

int NFWelfarePart::MakeCityPlayerData(proto_ff::CityRoleInfo* pGCCityRoleInfo)
{
    return 0;
}
